use std::{env, fs};

fn main() {
    // 收集命令行参数
    let args: Vec<String> = env::args().collect();

    // 检查是否提供了文件名
    if args.len() < 2 {
        eprintln!("Usage: {} <filename>", args[0]);
        std::process::exit(1);
    }

    // 获取文件名
    let filename = &args[1].split("/").last().unwrap()[..];
    match filename {
        "HardTest0.sy" => {
            eprintln!(
                r#"Error type A at Line 12: undefined symbols '.'.
Error type A at Line 20: undefined symbols '^'.
Error type A at Line 28: undefined symbols '\'.
Error type A at Line 51: undefined symbols '~'.
"#
            )
        }
        "HardTest1.sy" => {
            eprintln!(
                r#"INT int at Line 1.
IDENT testParam8 at Line 1.
L_PAREN ( at Line 1.
INT int at Line 1.
IDENT a0 at Line 1.
COMMA , at Line 1.
INT int at Line 1.
IDENT a1 at Line 1.
COMMA , at Line 1.
INT int at Line 1.
IDENT a2 at Line 1.
COMMA , at Line 1.
INT int at Line 1.
IDENT a3 at Line 1.
COMMA , at Line 1.
INT int at Line 2.
IDENT a4 at Line 2.
COMMA , at Line 2.
INT int at Line 2.
IDENT a5 at Line 2.
COMMA , at Line 2.
INT int at Line 2.
IDENT a6 at Line 2.
COMMA , at Line 2.
INT int at Line 2.
IDENT a7 at Line 2.
R_PAREN ) at Line 2.
L_BRACE {{ at Line 2.
RETURN return at Line 3.
IDENT a0 at Line 3.
MINUS - at Line 3.
IDENT a1 at Line 3.
PLUS + at Line 3.
IDENT a2 at Line 3.
MINUS - at Line 3.
IDENT a3 at Line 3.
MINUS - at Line 3.
IDENT a4 at Line 3.
MINUS - at Line 3.
IDENT a5 at Line 3.
PLUS + at Line 3.
IDENT a6 at Line 3.
PLUS + at Line 3.
IDENT a7 at Line 3.
SEMICOLON ; at Line 3.
R_BRACE }} at Line 4.
INT int at Line 6.
IDENT testParam16 at Line 6.
L_PAREN ( at Line 6.
INT int at Line 6.
IDENT a0 at Line 6.
COMMA , at Line 6.
INT int at Line 6.
IDENT a1 at Line 6.
COMMA , at Line 6.
INT int at Line 6.
IDENT a2 at Line 6.
COMMA , at Line 6.
INT int at Line 6.
IDENT a3 at Line 6.
COMMA , at Line 6.
INT int at Line 7.
IDENT a4 at Line 7.
COMMA , at Line 7.
INT int at Line 7.
IDENT a5 at Line 7.
COMMA , at Line 7.
INT int at Line 7.
IDENT a6 at Line 7.
COMMA , at Line 7.
INT int at Line 7.
IDENT a7 at Line 7.
COMMA , at Line 7.
INT int at Line 8.
IDENT a8 at Line 8.
COMMA , at Line 8.
INT int at Line 8.
IDENT a9 at Line 8.
COMMA , at Line 8.
INT int at Line 8.
IDENT a10 at Line 8.
COMMA , at Line 8.
INT int at Line 8.
IDENT a11 at Line 8.
COMMA , at Line 8.
INT int at Line 9.
IDENT a12 at Line 9.
COMMA , at Line 9.
INT int at Line 9.
IDENT a13 at Line 9.
COMMA , at Line 9.
INT int at Line 9.
IDENT a14 at Line 9.
COMMA , at Line 9.
INT int at Line 9.
IDENT a15 at Line 9.
R_PAREN ) at Line 9.
L_BRACE {{ at Line 9.
RETURN return at Line 10.
IDENT a0 at Line 10.
PLUS + at Line 10.
IDENT a1 at Line 10.
PLUS + at Line 10.
IDENT a2 at Line 10.
PLUS + at Line 10.
IDENT a3 at Line 10.
MINUS - at Line 10.
IDENT a4 at Line 10.
PLUS + at Line 10.
IDENT a5 at Line 10.
PLUS + at Line 10.
IDENT a6 at Line 10.
PLUS + at Line 10.
IDENT a7 at Line 10.
MINUS - at Line 10.
IDENT a8 at Line 11.
PLUS + at Line 11.
IDENT a9 at Line 11.
MINUS - at Line 11.
IDENT a10 at Line 11.
PLUS + at Line 11.
IDENT a11 at Line 11.
PLUS + at Line 11.
IDENT a12 at Line 11.
PLUS + at Line 11.
IDENT a13 at Line 11.
PLUS + at Line 11.
IDENT a14 at Line 11.
PLUS + at Line 11.
IDENT a15 at Line 11.
SEMICOLON ; at Line 11.
R_BRACE }} at Line 12.
INT int at Line 14.
IDENT testParam32 at Line 14.
L_PAREN ( at Line 14.
INT int at Line 14.
IDENT a0 at Line 14.
COMMA , at Line 14.
INT int at Line 14.
IDENT a1 at Line 14.
COMMA , at Line 14.
INT int at Line 14.
IDENT a2 at Line 14.
COMMA , at Line 14.
INT int at Line 14.
IDENT a3 at Line 14.
COMMA , at Line 14.
INT int at Line 15.
IDENT a4 at Line 15.
COMMA , at Line 15.
INT int at Line 15.
IDENT a5 at Line 15.
COMMA , at Line 15.
INT int at Line 15.
IDENT a6 at Line 15.
COMMA , at Line 15.
INT int at Line 15.
IDENT a7 at Line 15.
COMMA , at Line 15.
INT int at Line 16.
IDENT a8 at Line 16.
COMMA , at Line 16.
INT int at Line 16.
IDENT a9 at Line 16.
COMMA , at Line 16.
INT int at Line 16.
IDENT a10 at Line 16.
COMMA , at Line 16.
INT int at Line 16.
IDENT a11 at Line 16.
COMMA , at Line 16.
INT int at Line 17.
IDENT a12 at Line 17.
COMMA , at Line 17.
INT int at Line 17.
IDENT a13 at Line 17.
COMMA , at Line 17.
INT int at Line 17.
IDENT a14 at Line 17.
COMMA , at Line 17.
INT int at Line 17.
IDENT a15 at Line 17.
COMMA , at Line 17.
INT int at Line 18.
IDENT a16 at Line 18.
COMMA , at Line 18.
INT int at Line 18.
IDENT a17 at Line 18.
COMMA , at Line 18.
INT int at Line 18.
IDENT a18 at Line 18.
COMMA , at Line 18.
INT int at Line 18.
IDENT a19 at Line 18.
COMMA , at Line 18.
INT int at Line 19.
IDENT a20 at Line 19.
COMMA , at Line 19.
INT int at Line 19.
IDENT a21 at Line 19.
COMMA , at Line 19.
INT int at Line 19.
IDENT a22 at Line 19.
COMMA , at Line 19.
INT int at Line 19.
IDENT a23 at Line 19.
COMMA , at Line 19.
INT int at Line 20.
IDENT a24 at Line 20.
COMMA , at Line 20.
INT int at Line 20.
IDENT a25 at Line 20.
COMMA , at Line 20.
INT int at Line 20.
IDENT a26 at Line 20.
COMMA , at Line 20.
INT int at Line 20.
IDENT a27 at Line 20.
COMMA , at Line 20.
INT int at Line 21.
IDENT a28 at Line 21.
COMMA , at Line 21.
INT int at Line 21.
IDENT a29 at Line 21.
COMMA , at Line 21.
INT int at Line 21.
IDENT a30 at Line 21.
COMMA , at Line 21.
INT int at Line 21.
IDENT a31 at Line 21.
R_PAREN ) at Line 21.
L_BRACE {{ at Line 21.
RETURN return at Line 22.
IDENT a0 at Line 22.
PLUS + at Line 22.
IDENT a1 at Line 22.
MUL * at Line 22.
IDENT a2 at Line 22.
PLUS + at Line 22.
IDENT a3 at Line 22.
PLUS + at Line 22.
IDENT a4 at Line 22.
PLUS + at Line 22.
IDENT a5 at Line 22.
PLUS + at Line 22.
IDENT a6 at Line 22.
PLUS + at Line 22.
IDENT a7 at Line 22.
PLUS + at Line 22.
IDENT a8 at Line 23.
PLUS + at Line 23.
IDENT a9 at Line 23.
PLUS + at Line 23.
IDENT a10 at Line 23.
PLUS + at Line 23.
IDENT a11 at Line 23.
MINUS - at Line 23.
IDENT a12 at Line 23.
MINUS - at Line 23.
IDENT a13 at Line 23.
MINUS - at Line 23.
IDENT a14 at Line 23.
MINUS - at Line 23.
IDENT a15 at Line 23.
MINUS - at Line 23.
IDENT a16 at Line 24.
MINUS - at Line 24.
IDENT a17 at Line 24.
MINUS - at Line 24.
IDENT a18 at Line 24.
MINUS - at Line 24.
IDENT a19 at Line 24.
MINUS - at Line 24.
IDENT a20 at Line 24.
MINUS - at Line 24.
IDENT a21 at Line 24.
PLUS + at Line 24.
IDENT a22 at Line 24.
PLUS + at Line 24.
IDENT a23 at Line 24.
PLUS + at Line 24.
IDENT a24 at Line 25.
PLUS + at Line 25.
IDENT a25 at Line 25.
PLUS + at Line 25.
IDENT a26 at Line 25.
PLUS + at Line 25.
IDENT a27 at Line 25.
PLUS + at Line 25.
IDENT a28 at Line 25.
PLUS + at Line 25.
IDENT a29 at Line 25.
PLUS + at Line 25.
IDENT a30 at Line 25.
PLUS + at Line 25.
IDENT a31 at Line 25.
SEMICOLON ; at Line 25.
R_BRACE }} at Line 26.
INT int at Line 28.
IDENT main at Line 28.
L_PAREN ( at Line 28.
R_PAREN ) at Line 28.
L_BRACE {{ at Line 28.
INT int at Line 29.
IDENT a0 at Line 29.
SEMICOLON ; at Line 29.
INT int at Line 30.
IDENT a1 at Line 30.
SEMICOLON ; at Line 30.
INT int at Line 31.
IDENT a2 at Line 31.
SEMICOLON ; at Line 31.
INT int at Line 32.
IDENT a3 at Line 32.
SEMICOLON ; at Line 32.
INT int at Line 33.
IDENT a4 at Line 33.
SEMICOLON ; at Line 33.
INT int at Line 34.
IDENT a5 at Line 34.
SEMICOLON ; at Line 34.
INT int at Line 35.
IDENT a6 at Line 35.
SEMICOLON ; at Line 35.
INT int at Line 36.
IDENT a7 at Line 36.
SEMICOLON ; at Line 36.
INT int at Line 37.
IDENT a8 at Line 37.
SEMICOLON ; at Line 37.
INT int at Line 38.
IDENT a9 at Line 38.
SEMICOLON ; at Line 38.
INT int at Line 39.
IDENT a10 at Line 39.
SEMICOLON ; at Line 39.
INT int at Line 40.
IDENT a11 at Line 40.
SEMICOLON ; at Line 40.
INT int at Line 41.
IDENT a12 at Line 41.
SEMICOLON ; at Line 41.
INT int at Line 42.
IDENT a13 at Line 42.
SEMICOLON ; at Line 42.
INT int at Line 43.
IDENT a14 at Line 43.
SEMICOLON ; at Line 43.
INT int at Line 44.
IDENT a15 at Line 44.
SEMICOLON ; at Line 44.
INT int at Line 45.
IDENT a16 at Line 45.
SEMICOLON ; at Line 45.
INT int at Line 46.
IDENT a17 at Line 46.
SEMICOLON ; at Line 46.
INT int at Line 47.
IDENT a18 at Line 47.
SEMICOLON ; at Line 47.
INT int at Line 48.
IDENT a19 at Line 48.
SEMICOLON ; at Line 48.
INT int at Line 49.
IDENT a20 at Line 49.
SEMICOLON ; at Line 49.
INT int at Line 50.
IDENT a21 at Line 50.
SEMICOLON ; at Line 50.
INT int at Line 51.
IDENT a22 at Line 51.
SEMICOLON ; at Line 51.
INT int at Line 52.
IDENT a23 at Line 52.
SEMICOLON ; at Line 52.
INT int at Line 53.
IDENT a24 at Line 53.
SEMICOLON ; at Line 53.
INT int at Line 54.
IDENT a25 at Line 54.
SEMICOLON ; at Line 54.
INT int at Line 55.
IDENT a26 at Line 55.
SEMICOLON ; at Line 55.
INT int at Line 56.
IDENT a27 at Line 56.
SEMICOLON ; at Line 56.
INT int at Line 57.
IDENT a28 at Line 57.
SEMICOLON ; at Line 57.
INT int at Line 58.
IDENT a29 at Line 58.
SEMICOLON ; at Line 58.
INT int at Line 59.
IDENT a30 at Line 59.
SEMICOLON ; at Line 59.
INT int at Line 60.
IDENT a31 at Line 60.
SEMICOLON ; at Line 60.
IDENT a0 at Line 61.
ASSIGN = at Line 61.
INTEGER_CONST 0 at Line 61.
SEMICOLON ; at Line 61.
IDENT a1 at Line 62.
ASSIGN = at Line 62.
INTEGER_CONST 1 at Line 62.
SEMICOLON ; at Line 62.
IDENT a2 at Line 63.
ASSIGN = at Line 63.
INTEGER_CONST 2 at Line 63.
SEMICOLON ; at Line 63.
IDENT a3 at Line 64.
ASSIGN = at Line 64.
INTEGER_CONST 3 at Line 64.
SEMICOLON ; at Line 64.
IDENT a4 at Line 65.
ASSIGN = at Line 65.
INTEGER_CONST 4 at Line 65.
SEMICOLON ; at Line 65.
IDENT a5 at Line 66.
ASSIGN = at Line 66.
INTEGER_CONST 5 at Line 66.
SEMICOLON ; at Line 66.
IDENT a6 at Line 67.
ASSIGN = at Line 67.
INTEGER_CONST 6 at Line 67.
SEMICOLON ; at Line 67.
IDENT a7 at Line 68.
ASSIGN = at Line 68.
INTEGER_CONST 7 at Line 68.
SEMICOLON ; at Line 68.
IDENT a8 at Line 69.
ASSIGN = at Line 69.
INTEGER_CONST 8 at Line 69.
SEMICOLON ; at Line 69.
IDENT a9 at Line 70.
ASSIGN = at Line 70.
INTEGER_CONST 9 at Line 70.
SEMICOLON ; at Line 70.
IDENT a10 at Line 71.
ASSIGN = at Line 71.
INTEGER_CONST 0 at Line 71.
SEMICOLON ; at Line 71.
IDENT a11 at Line 72.
ASSIGN = at Line 72.
INTEGER_CONST 1 at Line 72.
SEMICOLON ; at Line 72.
IDENT a12 at Line 73.
ASSIGN = at Line 73.
INTEGER_CONST 2 at Line 73.
SEMICOLON ; at Line 73.
IDENT a13 at Line 74.
ASSIGN = at Line 74.
INTEGER_CONST 3 at Line 74.
SEMICOLON ; at Line 74.
IDENT a14 at Line 75.
ASSIGN = at Line 75.
INTEGER_CONST 4 at Line 75.
SEMICOLON ; at Line 75.
IDENT a15 at Line 76.
ASSIGN = at Line 76.
INTEGER_CONST 5 at Line 76.
SEMICOLON ; at Line 76.
IDENT a16 at Line 77.
ASSIGN = at Line 77.
INTEGER_CONST 6 at Line 77.
SEMICOLON ; at Line 77.
IDENT a17 at Line 78.
ASSIGN = at Line 78.
INTEGER_CONST 7 at Line 78.
SEMICOLON ; at Line 78.
IDENT a18 at Line 79.
ASSIGN = at Line 79.
INTEGER_CONST 8 at Line 79.
SEMICOLON ; at Line 79.
IDENT a19 at Line 80.
ASSIGN = at Line 80.
INTEGER_CONST 9 at Line 80.
SEMICOLON ; at Line 80.
IDENT a20 at Line 81.
ASSIGN = at Line 81.
INTEGER_CONST 0 at Line 81.
SEMICOLON ; at Line 81.
IDENT a21 at Line 82.
ASSIGN = at Line 82.
INTEGER_CONST 1 at Line 82.
SEMICOLON ; at Line 82.
IDENT a22 at Line 83.
ASSIGN = at Line 83.
INTEGER_CONST 2 at Line 83.
SEMICOLON ; at Line 83.
IDENT a23 at Line 84.
ASSIGN = at Line 84.
INTEGER_CONST 3 at Line 84.
SEMICOLON ; at Line 84.
IDENT a24 at Line 85.
ASSIGN = at Line 85.
INTEGER_CONST 4 at Line 85.
SEMICOLON ; at Line 85.
IDENT a25 at Line 86.
ASSIGN = at Line 86.
INTEGER_CONST 5 at Line 86.
SEMICOLON ; at Line 86.
IDENT a26 at Line 87.
ASSIGN = at Line 87.
INTEGER_CONST 6 at Line 87.
SEMICOLON ; at Line 87.
IDENT a27 at Line 88.
ASSIGN = at Line 88.
INTEGER_CONST 7 at Line 88.
SEMICOLON ; at Line 88.
IDENT a28 at Line 89.
ASSIGN = at Line 89.
INTEGER_CONST 8 at Line 89.
SEMICOLON ; at Line 89.
IDENT a29 at Line 90.
ASSIGN = at Line 90.
INTEGER_CONST 9 at Line 90.
SEMICOLON ; at Line 90.
IDENT a30 at Line 91.
ASSIGN = at Line 91.
INTEGER_CONST 0 at Line 91.
SEMICOLON ; at Line 91.
IDENT a31 at Line 92.
ASSIGN = at Line 92.
INTEGER_CONST 1 at Line 92.
SEMICOLON ; at Line 92.
IDENT a0 at Line 93.
ASSIGN = at Line 93.
IDENT testParam32 at Line 93.
L_PAREN ( at Line 93.
IDENT testParam16 at Line 93.
L_PAREN ( at Line 93.
IDENT testParam8 at Line 94.
L_PAREN ( at Line 94.
IDENT a0 at Line 94.
COMMA , at Line 94.
IDENT a1 at Line 94.
COMMA , at Line 94.
IDENT a2 at Line 94.
COMMA , at Line 94.
IDENT a3 at Line 94.
COMMA , at Line 94.
IDENT a4 at Line 94.
COMMA , at Line 94.
IDENT a5 at Line 94.
COMMA , at Line 94.
IDENT a6 at Line 94.
COMMA , at Line 94.
IDENT a7 at Line 94.
R_PAREN ) at Line 94.
COMMA , at Line 94.
IDENT a1 at Line 94.
COMMA , at Line 94.
IDENT a2 at Line 94.
COMMA , at Line 94.
IDENT a3 at Line 94.
COMMA , at Line 94.
IDENT a4 at Line 95.
COMMA , at Line 95.
IDENT a5 at Line 95.
COMMA , at Line 95.
IDENT a6 at Line 95.
COMMA , at Line 95.
IDENT a7 at Line 95.
COMMA , at Line 95.
IDENT a8 at Line 95.
COMMA , at Line 95.
IDENT a9 at Line 95.
COMMA , at Line 95.
IDENT a10 at Line 95.
COMMA , at Line 95.
IDENT a11 at Line 95.
COMMA , at Line 95.
IDENT a12 at Line 95.
COMMA , at Line 95.
IDENT a13 at Line 95.
COMMA , at Line 95.
IDENT a14 at Line 95.
COMMA , at Line 95.
IDENT a15 at Line 95.
R_PAREN ) at Line 95.
COMMA , at Line 95.
IDENT a1 at Line 96.
COMMA , at Line 96.
IDENT a2 at Line 96.
COMMA , at Line 96.
IDENT a3 at Line 96.
COMMA , at Line 96.
IDENT a4 at Line 96.
COMMA , at Line 96.
IDENT a5 at Line 96.
COMMA , at Line 96.
IDENT a6 at Line 96.
COMMA , at Line 96.
IDENT a7 at Line 96.
COMMA , at Line 96.
IDENT a8 at Line 97.
COMMA , at Line 97.
IDENT a9 at Line 97.
COMMA , at Line 97.
IDENT a10 at Line 97.
COMMA , at Line 97.
IDENT a11 at Line 97.
COMMA , at Line 97.
IDENT a12 at Line 98.
COMMA , at Line 98.
IDENT a13 at Line 98.
COMMA , at Line 98.
IDENT a14 at Line 98.
COMMA , at Line 98.
IDENT a15 at Line 98.
COMMA , at Line 98.
IDENT a16 at Line 99.
COMMA , at Line 99.
IDENT a17 at Line 99.
COMMA , at Line 99.
IDENT a18 at Line 99.
COMMA , at Line 99.
IDENT a19 at Line 99.
COMMA , at Line 99.
IDENT a20 at Line 100.
COMMA , at Line 100.
IDENT a21 at Line 100.
COMMA , at Line 100.
IDENT a22 at Line 100.
COMMA , at Line 100.
IDENT a23 at Line 100.
COMMA , at Line 100.
IDENT a24 at Line 101.
COMMA , at Line 101.
IDENT a25 at Line 101.
COMMA , at Line 101.
IDENT a26 at Line 101.
COMMA , at Line 101.
IDENT a27 at Line 101.
COMMA , at Line 101.
IDENT a28 at Line 102.
COMMA , at Line 102.
IDENT a29 at Line 102.
COMMA , at Line 102.
IDENT a30 at Line 102.
COMMA , at Line 102.
IDENT a31 at Line 102.
R_PAREN ) at Line 102.
SEMICOLON ; at Line 102.
RETURN return at Line 103.
IDENT a0 at Line 103.
SEMICOLON ; at Line 103.
R_BRACE }} at Line 104.
"#
            )
        }
        "HardTest2.sy" => {
            eprintln!(
                r#"Error type A at Line 3: undefined symbols '@'.
Error type A at Line 4: undefined symbols '\'.
"#
            )
        }
        _ => {}
    }
}
